package com.hgyc.mom.qms.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import com.hgyc.mom.qms.entity.QmsTemplateMaterial;
import com.hgyc.mom.qms.service.QmsTemplateMaterialService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 检测模板-物料Controller
 *
 * @author fwj
 * @since 2025-09-26
 */
@Tag(name = "检测模板-物料控制器", description = "检测模板-物料控制器")
@RestController
@RequestMapping("/qms/template/material")
public class QmsTemplateMaterialController {
    @Autowired
    private QmsTemplateMaterialService qmsTemplateMaterialService;


    @Operation(summary = "查询检测模板-物料树列表", description = "查询检测模板-物料树列表")
    @PostMapping("/list")
    public Result<List<QmsTemplateMaterial>> pageList(@Parameter(description = "查询参数") @RequestBody QmsTemplateMaterial qmsTemplateMaterial) {
        QueryWrapper<QmsTemplateMaterial> wrapper = QueryWrapperUtil.build(qmsTemplateMaterial);
        List<QmsTemplateMaterial> list = qmsTemplateMaterialService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取检测模板-物料详细信息", description = "获取检测模板-物料详细信息")
    @GetMapping(value = "/{id}")
    public Result<QmsTemplateMaterial> getInfo(@Parameter(description = "检测模板-物料ID") @PathVariable("id") Long id) {
        return Result.success(qmsTemplateMaterialService.getById(id));
    }

}
